package com.jinunn.hosp.controller;

import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleOrderVo;
import com.atguigu.yygh.vo.order.SignInfoVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jinunn.common.result.Result;
import com.jinunn.hosp.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author JinDnn
 * @date 2021/5/9 16:11
 */
@Api(value = "排班接口")
@RestController
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    @ApiOperation("查询排班的规则数据")
    @GetMapping("getScheduleRule/{page}/{limit}/{hosCode}/{depCode}")
    public Result<Map<String,Object>> getScheduleRule(@PathVariable("page") Integer page,
                                 @PathVariable("limit") Integer limit,
                                 @PathVariable("hosCode") String hosCode,
                                 @PathVariable("depCode") String depCode){
        Map<String,Object> map = scheduleService.getScheduleRule(page,limit,hosCode,depCode);
        return Result.ok(map);
    }

    @ApiOperation("查询排版详情")
    @GetMapping("getScheduleDetail/{hosCode}/{depCode}/{workDate}")
    public Result<List<Schedule>> getScheduleDetial(@PathVariable("hosCode") String hosCode,
                                    @PathVariable("depCode") String depCode,
                                    @PathVariable("workDate") String workDate){
        List<Schedule> list = scheduleService.getScheduleDetail(hosCode,depCode,workDate);
        return Result.ok(list);
    }

    @ApiOperation("根据排班id获取排班数据")
    @GetMapping("getSchedule/{scheduleId}")
    public Result<Schedule> getSchedule(@PathVariable("scheduleId") String scheduleId){
        Schedule schedule = scheduleService.getScheduleById(scheduleId);
        return Result.ok(schedule);
    }


    @ApiOperation("根据排班id获取预约下单数")
    @GetMapping("inner/getScheduleOrder/{scheduleId}")
    public ScheduleOrderVo getScheduleOrder(@PathVariable("scheduleId") Long scheduleId){
        return scheduleService.getScheduleOrder(scheduleId);
    }
}
